<template>
  <div class="login-page">
    <el-card class="box-card">
      <template #header>
        <div class="card-header">
          <span>登录</span>
        </div>
      </template>

      <el-form :model="from" label-width="100px" @sbmit.prevent="handleLogin">
        <el-form-item label="用户名">
          <el-input v-model="from.username"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input v-model="from.password"></el-input>
          </el-form-item>
          <el-form-item>
            <!--添加native-type="submit"用于触发handleLogin -->
            <el-button type="primary" native-type="submit">登录</el-button>
          </el-form-item>
      </el-form>
    </el-card>

  </div>
  </template>

<style scoped>
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 33vh;
  background: #f0f2f5;
}

.box-card{
  width: 400px;
  padding: 20px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.card-header{
  text-align: center;
}
</style>

<script>
import {ref} from "vue";
import {ElNotification} from "element-plus";
import router from "../router/index.js";

export default {
  setup(){
    const from = ref({username: "",password:""});
    const handleLogin = () => {
      //固定验证用户名和密码
      if(from.value.username === "admin" && from.value.password === admin"){
          //
      location.setItem("isAuthenticated",'true');
      ElNotification.success({
      title:'成功',
          message:'登录成功'
      type:"success"
    })

return {from,handleLogin}
  }
}
</script>